***This STATA code replicates the figures and tables in "Partisan Intensity in Congress: Evidence from Brett Kavanaugh's Supreme Court Nomination."
***The data is split into three .dta files. The first includes the data used for the main body of the paper. The second and third are used to produce the findings in the Supplementary Materials.
***The code was run using STATA version 14.2 and I used the user-generated packaged combomarginsplot. 

*Open the Kavanaugh_PRQ_MainReplicationData.dta file
use "Kavanaugh_PRQ_MainReplicationData.dta"

***Figure 1***
collapse (sum) mention_kav, by(edate)
gen date2 = edate
format date2 %dd_M
twoway (bar mention_kav date2, sort), xlabel(minmax 21441, labsize(vsmall) labcolor(black)) xline(21441) ytitle("Percentage of Senators") xtitle("Date") ylabel(,labcolor(black))
clear
****************

*To create Tables and subsequent figures, clear the data and reload the main replication data file:
use "Kavanaugh_PRQ_MainReplicationData.dta"
***Table 3****
*Model 1
logit mention_kav  i.reelection18##c.pvi judiciary i.woman##i.democrat##i.post_ford  ideologue party_leader former_house years_served age tweets115th, vce(cluster icpsr)
*Model 2
logit mention_kav_noissue i.reelection18##c.pvi judiciary i.woman##i.democrat##i.post_ford  ideologue party_leader former_house years_served age tweets115th, vce(cluster icpsr)
*Model 3
fracreg logit perc_kav i.reelection18##c.pvi judiciary i.woman##i.democrat##i.post_ford  ideologue party_leader former_house years_served age tweets115th, vce(cluster icpsr)
*Model 4
fracreg logit perc_kav_noissue i.reelection18##c.pvi judiciary i.woman##i.democrat##i.post_ford  ideologue party_leader former_house years_served age tweets115th, vce(cluster icpsr)
*Model 5
nbreg count_kav i.reelection18##c.pvi judiciary i.woman##i.democrat##i.post_ford  ideologue party_leader former_house years_served age tweets115th, exposure(expose) vce(cluster icpsr)
*Model 6
nbreg count_kav_noissue i.reelection18##c.pvi judiciary i.woman##i.democrat##i.post_ford ideologue party_leader former_house years_served age tweets115th, exposure(expose) vce(cluster icpsr)


***Figure 2***
*Creating Figure 2 requires installing the combomarginsplot module. 
logit mention_kav_noissue judiciary i.woman##i.democrat##i.post_ford i.reelection18##c.pvi c.ideologue i.party_leader former_house years_served age tweets115th, vce(cluster icpsr)
margins, dydx(post_ford) at(democrat=1 woman=1) saving(n1, replace)
margins, dydx(post_ford) at(democrat=0 woman=1) saving(n2, replace)
margins, dydx(post_ford) at(democrat=1 woman=0) saving(n3, replace)
margins, dydx(post_ford) at(democrat=0 woman=0) saving(n4, replace)
combomarginsplot n1 n2 n3 n4, labels("Democratic Woman" "Republican Woman" "Democratic Man" "Republican Man") file1opts(lpattern(blank)) file2opts(lpattern(blank) color(black)) fileci2opts(acolor(black)) title("") ytitle("Marginal Change in Probability") xscale(range(0.75, 4.25)) yscale(range(-0.2, 0.25)) xtitle("") xlabel(,labcolor(black)) ylabel(,labcolor(black))

*******Supplementary Materials*******
*Open the Kavanaugh_PRQ_Senate21DayRandomSample dataset
use "Kavanaugh_PRQ_Senate21DayRandomSample.dta"
***Table 4***
logit day_partisan judiciary i.woman##i.democrat##i.post_ford i.reelection18##c.pvi ideologue party_leader former_house years_served age tweets115th, vce(cluster icpsr)
fracreg logit perc_partisan judiciary i.woman##i.democrat##i.post_ford i.reelection18##c.pvi ideologue party_leader former_house years_served age tweets115th, vce(cluster icpsr)
nbreg partisan judiciary i.woman##i.democrat##i.post_ford i.reelection18##c.pvi ideologue party_leader former_house years_served age tweets115th, exposure(expose) vce(cluster icpsr)


*Open the Kavanaugh_PRQ_HouseData dataset
use "Kavanaugh_PRQ_HouseData.dta"
***Table 5***
logit mention_kav judiciary i.reelection##c.pvi i.woman##i.democrat##i.post_ford  ideologue party_leader years_served age tweets115th, vce(cluster icpsr)
fracreg logit perc_kav judiciary i.reelection##c.pvi i.woman##i.democrat##i.post_ford ideologue party_leader years_served age tweets115th, vce(cluster icpsr)
nbreg count_kav judiciary i.reelection##c.pvi i.woman##i.democrat##i.post_ford ideologue party_leader years_served age tweets115th, exposure(expose) vce(cluster icpsr)




